# Maintainer: BlackIkeEagle <ike DOT devolder AT gmail DOT com>

pkgname=kodi-addon-imagedecoder-heif
pkgver=20.1.0
_codename=Nexus
pkgrel=6
pkgdesc="Kodi heif/heic imagedecoder addon"
arch=('loong64' 'x86_64')
url="https://github.com/xbmc/imagedecoder.heif"
license=('GPL2')
groups=('kodi-addons' 'kodi-addons-imagedecoder')
makedepends=('cmake' 'kodi-dev' 'libheif' 'tinyxml2')
options=(!lto)
source=("$pkgname-$pkgver.tar.gz::https://github.com/xbmc/imagedecoder.heif/archive/refs/tags/$pkgver-$_codename.tar.gz"
        'https://github.com/xbmc/imagedecoder.heif/commit/47dcb3843e02abb69c52d6f0021bd2816b8317a5.patch'
)
sha512sums=('9e481b52aeb1373164a4f60059730620b812ef944dd56c500a603b4dd0cb2974cb72eb0968277c678287dd8b946f83ee37b8c54bc84172f1451b0c04ca6984f3'
            '5ebbeece8f24c0df3fdbbd3b2b4556ca61b3361c92d7577c7fd19b61af6a40f34cdc4459d4aa226160ddced71080bdfdff42e15a750913ce5271631b1c2d04be')

prepare() {
    cd "imagedecoder.heif-$pkgver-$_codename"
    patch -p1 -i "$srcdir/47dcb3843e02abb69c52d6f0021bd2816b8317a5.patch"
}

build() {
    cd "imagedecoder.heif-$pkgver-$_codename"
    cmake \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_SHARED_LIBS=1 \
        -DUSE_LTO=1 \
        .
    make
}

package() {
    depends=('kodi' 'libheif' 'tinyxml2')
    cd "imagedecoder.heif-$pkgver-$_codename"
    make DESTDIR="$pkgdir/" install
}
